using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditor.UIElements;

public static class VisualElementExtensions 
{

    //public struct DoubleClickDesc
    //{
    //    public int MouseDownCount;
    //    public float LastMouseDownTime;
    //}

    //private static Dictionary<VisualElement, Dictionary<EventCallback<MouseUpEvent>, DoubleClickDesc>> mDoubleClickDescDict = new Dictionary<VisualElement, Dictionary<EventCallback<MouseUpEvent>, DoubleClickDesc>>();

    //public static void RegisterDoubleClickCallback(this VisualElement element, EventCallback<MouseUpEvent> callback, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown)
    //{
    //    if (!mDoubleClickDescDict.TryGetValue(element, out var callbacks))
    //    {
    //        callbacks = new Dictionary<EventCallback<MouseUpEvent>, DoubleClickDesc>();
    //        mDoubleClickDescDict.Add(element, callbacks);
    //    }
        
    //    if (callbacks.ContainsKey(callback))
    //    {
    //        Debug.LogError("RegisterDoubleClickCallback Fail!");
    //        return;
    //    }

    //    callbacks.Add(callback, new DoubleClickDesc());

    //    element.RegisterCallback<DetachFromPanelEvent>(OnElementDetachFromPanelEvent);
    //    element.RegisterCallback<MouseDownEvent>(TempMouseDownEvent, useTrickleDown);
    //    element.RegisterCallback<MouseUpEvent>(callback, useTrickleDown);
    //}


    //private static void OnElementDetachFromPanelEvent(DetachFromPanelEvent e)
    //{
    //    if(e.destinationPanel == null)
    //    {
    //        var element = e.target as VisualElement;
    //        mDoubleClickDescDict.Remove(element);
    //        Debug.Log("Deleted!");
    //    }
    //}

    //private static void TempMouseDownEvent(MouseDownEvent e)
    //{
    //}

}
